package com.zephyr.vchcenter.bpm.decision;

import org.apache.log4j.Logger;

import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.RuleException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.bpm.rule.Decision;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.action.WsIdAction;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class NeedIdDecisionHandler extends Decision {
	private final Logger log = Logger.getLogger(NeedIdDecisionHandler.class);
	@Override
	public void exceptionHandle(ServiceContext arg0) {
		

	}

	@Override
	public String make(ServiceContext arg0) throws RuleException,
			ServiceException, ParameterException {
		log.debug("进入NeedIdDecisionHandler.........");
		String vchsid=(String)arg0.getInputParameterValue("vchsid");
		IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
        Voucher voucher=(Voucher)dao.findById("Voucher",vchsid);
		String sysidres=voucher.getSysidres();
		log.debug("�Զ�������"+sysidres);
		String transition=null;
		if(("1").equals(sysidres)){
			voucher.setIdresult("2");
			transition="to joinResultDecision";
		}else{
			voucher.setIdstate("1");
			transition="to identify";
		}
		dao.saveOrUpdate(voucher);
		log.debug("���ת��"+transition);
		log.debug("����NeedIdDecisionHandlerlikai  离开NeedIdDecisionHandler................");
		return transition;
	}

}
